
CC := aarch64-linux-gnu-gcc
# CC32 := aarch64-linux-gnu-gcc
# CC := armclang --target=aarch64-arm-none-eabi -march=armv8-a
# CC32 := armclang --target=aarch64-arm-none-eabi -march=armv8-a
# CC32 := armclang --target=arm-arm-none-eabi -march=armv8-a
CC32 := armv8l-linux-gnueabihf-gcc 
LD32 := armv8l-linux-gnueabihf-ld

LD := aarch64-linux-gnu-ld
OBJDUMP := aarch64-linux-gnu-objdump
OBJCOPY := aarch64-linux-gnu-objcopy

TARGET := hk

ifeq ($(TARGET),hk)
CFLAGS := -DUART_ADDR=0x70000000
# CFLAGS := -DUART_ADDR=0x70001000
endif
ifeq ($(TARGET),avk)
CFLAGS := -DUART_ADDR=0x13000000
endif

TARGET := t

exec.elf: boot.o main.o
	$(LD) -Tlink.lds $^ -o $(TARGET)_$@.elf
	$(OBJDUMP) -d $(TARGET)_$@.elf > $(TARGET)_$@.asm
	$(OBJCOPY) -O binary $(TARGET)_$@.elf  $(TARGET)_$@.bin
	# ./parse_hex.py $(TARGET)_$@.bin $(TARGET)_$@.hex

%-a32.o: %-a32.S
	$(CC32) $(CFLAGS) -c -o $@ $^

%.o: %.S
	$(CC) $(CFLAGS) -c -o $@ $^


# %-a32.o: %-a32.c
# 	$(CC32) -c -o $@ $^

# %.o: %.c
# 	$(CC) -c -o $@ $^

clean:
	rm *.o test *.bin boot *.asm *.elf *.log *.tarmac a32-serial-bini.S *.hex